ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
DSPI.c File Reference

Serial Peripheral Interface drivers. More...

#include "derivative.h"
#include "DSPI.h"

Functions

uint8_t u8fnDSPITranscieve (const uint8_t u8MyInstanceWCTAR, const uint8_t u8CSEnable, uint16_t *pu16DSPITx, uint16_t *pu16DSPIRx, const uint8_t u8Size)
 This routine will, once the corresponding DSPI instance has been configured, send and receive any number of words through interrupts. Note that this means that at the exit of this routine, the message might still be ongoing.
void vfnDSPIEnable (const DSPIInstance_t tMyInstance, const uint8_t u8CSEnable, const uint8_t u8Start)
 Enables or disables a particular DSPI transmission. used by u8fnDSPITranscieve.
uint32_t u32fnDSPIStatus (uint8_t u8Instance)
 This routine returns the status register for a given instance.
uint8_t u8fnConfigDSPIGeneral (const DSPIConfig_t *tDSPIConfig)
 Configures a particular DSPI instance with general settings on how it is to be used.
uint8_t u8fnConfigDSPIPreset (const DSPIPresetConfig_t *tDSPIConfig)
 This routine will configure a particular preset configuration within an SPI instance.
uint8_t u8fnIsDSPIBusy (uint8_t u8Instance)
 returns DSPI_BUSY_WITH_PREVIOUS_TX based on the state of HW bit SPI HALT
uint32_t u32fnFormatDSPIPUSHR (uint8_t u8DSPIInstanceWCTAR, uint8_t u8CS, uint8_t u8ContCS, uint8_t u8EndOfQueueFlag, uint16_t u16Msg)
 Formats a 16-bit word for placement in PUSHR and transmission.
uint8_t u8fnDSPISwitchIsrMode (uint8_t u8DSPIInstanceWCTAR, uint8_t u8IsrMode)
 Switches between Interrupt-enabled SPI and DMA-enabled SPI.
void vfnDSPI0FUFISR (void)
 DSPI0's interrupt vector for the FUF flag. It calls a generic routine.
void vfnDSPI1FUFISR (void)
 DSPI1's interrupt vector for the FUF flag. It calls a generic routine.
void vfnDSPI2FUFISR (void)
 DSPI2's interrupt vector for the FUF flag. It calls a generic routine.
void vfnDSPI3FUFISR (void)
 DSPI3's interrupt vector for the FUF flag. It calls a generic routine.
void vfnDSPI0TCFIsr (void)
 DSPI0's interrupt vector for the Transmission Complete flag. It calls a generic routine.
void vfnDSPI1TCFIsr (void)
 DSPI1's interrupt vector for the Transmission Complete flag. It calls a generic routine.
void vfnDSPI2TCFIsr (void)
 DSPI2's interrupt vector for the Transmission Complete flag. It calls a generic routine.
void vfnDSPI3TCFIsr (void)
 DSPI3's interrupt vector for the Transmission Complete flag. It calls a generic routine.
void vfnDSPI0RFDFIsr (void)
 DSPI0's interrupt vector for the RFDF flag. It calls a generic routine.
void vfnDSPI1RFDFIsr (void)
 DSPI1's interrupt vector for the RFDF flag. It calls a generic routine.
void vfnDSPI2RFDFIsr (void)
 DSPI2's interrupt vector for the RFDF flag. It calls a generic routine.
void vfnDSPI3RFDFIsr (void)
 DSPI3's interrupt vector for the RFDF flag. It calls a generic routine.
void vfnDSPI0EOQIsr (void)
 DSPI0's interrupt vector for the End-ofQue flag. It calls a generic routine.
void vfnDSPI1EOQIsr (void)
 DSPI1's interrupt vector for the End-ofQue flag. It calls a generic routine.
void vfnDSPI2EOQIsr (void)
 DSPI2's interrupt vector for the End-ofQue flag. It calls a generic routine.
void vfnDSPI3EOQIsr (void)
 DSPI3's interrupt vector for the End-ofQue flag. It calls a generic routine.
void vfnDSPI0TFFFIsr (void)
 DSPI0's interrupt vector for the TFFF flag. It calls a generic routine.
void vfnDSPI1TFFFIsr (void)
 DSPI1's interrupt vector for the TFFF flag. It calls a generic routine.
void vfnDSPI2TFFFIsr (void)
 DSPI2's interrupt vector for the TFFF flag. It calls a generic routine.
void vfnDSPI3TFFFIsr (void)
 DSPI3's interrupt vector for the TFFF flag. It calls a generic routine.

Variables

const uint8_t cau8DSPIInstances [N_DSPI_INSTANCES *N_DSPI_PRESETS]
const DSPI_t catDSPIInstances [N_DSPI_INSTANCES]
vuint8_t gau8DSPIBuffSize [N_DSPI_INSTANCES]
vuint8_t gau8DSPIWordsRx [N_DSPI_INSTANCES]
vuint8_t gau8DSPITransferSize [N_DSPI_INSTANCES]
vuint8_t gau8DSPITxFIFOIsEnabled [N_DSPI_INSTANCES]
vuint8_t gau8DSPIRxFIFOIsEnabled [N_DSPI_INSTANCES]
vuint16_t * gpu16DSPITxBuffer [N_DSPI_INSTANCES]
vuint16_t * gpu16DSPIRxBuffer [N_DSPI_INSTANCES]
vuint8_t * gpu8DSPITxBuffer [N_DSPI_INSTANCES]
vuint8_t * gpu8DSPIRxBuffer [N_DSPI_INSTANCES]

Detailed Description

Serial Peripheral Interface drivers.

Copyright (c) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
R11515
Version:
Date:
Warning:
(If needed)

History:


Function Documentation

uint32_t u32fnDSPIStatus ( uint8_t  u8Instance)

This routine returns the status register for a given instance.

Parameters:
u8MyInstance,:8-bit word with the correct instance (0 - 3 for Pictus).
Returns:
Status word as defined by HW:
  • BIT31: Transfer complete flag
  • BIT30: Tx/Rx enabled (when 1)
  • BIT28: End of queue flag
  • BIT27: Transmit FIFO underflow flag
  • BIT25: Transmit FIFO fill flag
  • BIT19: Receive FIFO overflow flag
  • BIT18: Receive FIFO drain flag
  • BIT15:12: Tx FIFO counter (counts elements in FIFO)
  • BIT11:8: Next FIFO element to be sent
  • BIT7:4: Rx FIFO counter (counts elements in the FIFO)
  • BIT3:0: Next FIFO element to be read
uint32_t u32fnFormatDSPIPUSHR ( uint8_t  u8DSPIInstance,
uint8_t  u8CS,
uint8_t  u8ContCS,
uint8_t  u8EndOfQueueFlag,
uint16_t  u16Msg 
)

Formats a 16-bit word for placement in PUSHR and transmission.

Parameters:
u8DSPIInstance,:A combination of SPI instance and CTAR. Only CTAR is used.
u8CS,:Mask to the active chip select.
u8ContCS,:1 if chip select should be continuous with next word, 0 otherwise.
u8EndOfQueueFlag,:1 if the EndOfQueue should be set at the end of the transmission, possibly generating and EOQ interrupt, 0 otherwise.
u16Msg,:the 16-bit word to be added to the register.
Returns:
32-bit PUSHR register.
uint8_t u8fnConfigDSPIGeneral ( const DSPIConfig_t tDSPIConfig)

Configures a particular DSPI instance with general settings on how it is to be used.

Parameters:
tDSPIConfig,:Structure with Instance and configuration to be used.
Returns:
DSPI_NOT_HALTED if we are not allowed to configure, zero otherwise
uint8_t u8fnConfigDSPIPreset ( const DSPIPresetConfig_t tDSPIConfig)

This routine will configure a particular preset configuration within an SPI instance.

Parameters:
tDSPIConfig,:Pointer to a structure containing the preset config.
Returns:
u8Status: Always CLEAR
uint8_t u8fnDSPISwitchIsrMode ( uint8_t  u8DSPIInstance,
uint8_t  u8IsrMode 
)

Switches between Interrupt-enabled SPI and DMA-enabled SPI.

Parameters:
u8DSPIInstance,:0 - 3, depending on which SPI instance will be used.
u8IsrMode,:DSPI_ENABLE_DMA_DISABLE_ISR or DSPI_DISABLE_DMA_ENABLE_ISR
Returns:
u8Status: Always CLEAR.
uint8_t u8fnDSPITranscieve ( const uint8_t  u8MyInstance,
const uint8_t  u8CSEnable,
uint16_t *  pu16DSPITx,
uint16_t *  pu16DSPIRx,
const uint8_t  u8Size 
)

This routine will, once the corresponding DSPI instance has been configured, send and receive any number of words through interrupts. Note that this means that at the exit of this routine, the message might still be ongoing.

Parameters:
u8MyInstance,:8-bit word containing both the DSPI instance and the preset configuration to be used, using the format defined in DSPIInstance_t.
u8CSEnable,:Selects which Chip Select will be used. Bit dependant: BIT0 = CS0, BIT1 = CS1 and so on...
pu16DSPITx,:Pointer to Buffer to be transmitted. Note that buffers containing 8-bit words will be handled accordingly, but must be cast explicitly to 16-bit pointers to call the routine.
pu16DSPIRx,:Pointer to buffer where data will be received. Note that buffers containing 8-bit words will be handled accordingly, but must be cast explicitly to 16-bit pointers to call the routine
u8Size,:Size of buffer to be transmitted.
Returns:
u8Status: Zero if no problems found; DSPI_BUSY_WITH_PREVIOUS_TX if the HW is busy and cannot transmit existing data.
uint8_t u8fnIsDSPIBusy ( uint8_t  u8Instance)

returns DSPI_BUSY_WITH_PREVIOUS_TX based on the state of HW bit SPI HALT

Parameters:
u8Instance,:0 - 3, depending on which SPI instance will be used.
Returns:
u8Status: DSPI_BUSY_WITH_PREVIOUS_TX if busy, 0 otherwise.
void vfnDSPI0EOQIsr ( void  )

DSPI0's interrupt vector for the End-ofQue flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI0FUFISR ( void  )

DSPI0's interrupt vector for the FUF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI0RFDFIsr ( void  )

DSPI0's interrupt vector for the RFDF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI0TCFIsr ( void  )

DSPI0's interrupt vector for the Transmission Complete flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI0TFFFIsr ( void  )

DSPI0's interrupt vector for the TFFF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI1EOQIsr ( void  )

DSPI1's interrupt vector for the End-ofQue flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI1FUFISR ( void  )

DSPI1's interrupt vector for the FUF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI1RFDFIsr ( void  )

DSPI1's interrupt vector for the RFDF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI1TCFIsr ( void  )

DSPI1's interrupt vector for the Transmission Complete flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI1TFFFIsr ( void  )

DSPI1's interrupt vector for the TFFF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI2EOQIsr ( void  )

DSPI2's interrupt vector for the End-ofQue flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI2FUFISR ( void  )

DSPI2's interrupt vector for the FUF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI2RFDFIsr ( void  )

DSPI2's interrupt vector for the RFDF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI2TCFIsr ( void  )

DSPI2's interrupt vector for the Transmission Complete flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI2TFFFIsr ( void  )

DSPI2's interrupt vector for the TFFF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI3EOQIsr ( void  )

DSPI3's interrupt vector for the End-ofQue flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI3FUFISR ( void  )

DSPI3's interrupt vector for the FUF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI3RFDFIsr ( void  )

DSPI3's interrupt vector for the RFDF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI3TCFIsr ( void  )

DSPI3's interrupt vector for the Transmission Complete flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPI3TFFFIsr ( void  )

DSPI3's interrupt vector for the TFFF flag. It calls a generic routine.

Parameters:
void.
Returns:
void.
void vfnDSPIEnable ( const DSPIInstance_t  tMyInstance,
const uint8_t  u8CSEnable,
const uint8_t  u8Start 
)

Enables or disables a particular DSPI transmission. used by u8fnDSPITranscieve.

Parameters:
tMyInstance,:Structure with Instance and configuration to be used.
u8CSEnable,:Selects which Chip Select will be used. Bit dependant: BIT0 = CS0, BIT1 = CS1 and so on...
u8Start,:Enables the transmission/reception if non-zero, otherwise disables it.
Returns:
void.

Variable Documentation

const DSPI_t catDSPIInstances[N_DSPI_INSTANCES]
Initial value:
{
  &DSPI_0, &DSPI_1, &DSPI_2, &DSPI_3 }

List of pointers to each instance initial memory location

const uint8_t cau8DSPIInstances[N_DSPI_INSTANCES *N_DSPI_PRESETS]
Initial value:
{
  DSPI0C0, DSPI0C1, DSPI0C2, DSPI0C3, DSPI0C4, DSPI0C5, DSPI0C6, DSPI0C7,
  DSPI1C0, DSPI1C1, DSPI1C2, DSPI1C3, DSPI1C4, DSPI1C5, DSPI1C6, DSPI1C7,
  DSPI2C0, DSPI2C1, DSPI2C2, DSPI2C3, DSPI2C4, DSPI2C5, DSPI2C6, DSPI2C7,
  DSPI3C0, DSPI3C1, DSPI3C2, DSPI3C3, DSPI3C4, DSPI3C5, DSPI3C6, DSPI3C7 }

List of all instances and preset configurations available

vuint8_t gau8DSPIBuffSize[N_DSPI_INSTANCES]

Size of buffer to transmit (per instance)

vuint8_t gau8DSPIRxFIFOIsEnabled[N_DSPI_INSTANCES]

Flag to determine if DSPI's hardware FIFO is being used or not (Rx)

vuint8_t gau8DSPITransferSize[N_DSPI_INSTANCES]

Size of word to transmit per instance (16 or 8-bit)

vuint8_t gau8DSPITxFIFOIsEnabled[N_DSPI_INSTANCES]

Flag to determine if DSPI's hardware FIFO is being used or not (Tx)

vuint8_t gau8DSPIWordsRx[N_DSPI_INSTANCES]

Number of words received (per instance)

vuint16_t* gpu16DSPIRxBuffer[N_DSPI_INSTANCES]

Globals for 16-bit transfers (Rx)

vuint16_t* gpu16DSPITxBuffer[N_DSPI_INSTANCES]

Globals for 16-bit transfers (Tx)

vuint8_t* gpu8DSPIRxBuffer[N_DSPI_INSTANCES]

Globals for 8-bit transfers (Rx)

vuint8_t* gpu8DSPITxBuffer[N_DSPI_INSTANCES]

Globals for 8-bit transfers (Tx)